local skel = fk.CreateSkill {
  name = "lb__mingxian",
}

Fk:loadTranslationTable {
  ["lb__mingxian"] = "鸣弦",
  [":lb__mingxian"] = "每回合限一次，当一名角色使用【杀】指定唯一目标后，你可将一张【杀】置于目标武将牌上，令之不可被响应，然后你摸两张牌。若目标武将牌上已有「<b>鸣弦</b>」牌，则改为弃置一张【杀】。",

  ["#lb__mingxian-put"] = "鸣弦：你可以将一张【杀】置于 %dest 武将牌上，令 %dest 无法响应",
  ["#lb__mingxian-dis"] = "鸣弦：你可以弃置一张【杀】，令 %dest 无法响应",

  ["$lb__mingxian1"] = "气冲云霄！",
  ["$lb__mingxian2"] = "势如疾风！",
}

skel:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(self) and data.card.trueName == "slash" and
        data:isOnlyTarget(data.to) and player:usedSkillTimes(skel.name) == 0
  end,
  on_cost = function(self, event, target, player, data)
    if table.find(player:getCardIds("h"), function(id)
          return Fk:getCardById(id).trueName == "slash"
        end) then
      local room = player.room
      local cards = {}
      local t = data.to
      if #t:getPile("lb__mingxian") == 0 then
        cards = room:askToCards(player, {
          min_num = 1,
          max_num = 1,
          include_equip = false,
          skill_name = skel.name,
          cancelable = true,
          prompt = "#lb__mingxian-put::" .. t.id,
          pattern = "slash",
        })
        event:setCostData(self, { cards = cards })
      else
        cards = room:askToDiscard(player, {
          min_num = 1,
          max_num = 1,
          prompt = "#lb__mingxian-dis::" .. t.id,
          skill_name = "lb__mingxian",
          include_equip = false,
          pattern = "slash",
        })
        event:setCostData(self, { cards = false })
      end
      return #cards > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    local cards = event:getCostData(self).cards
    if cards then
      data:getAllTargets()[1]:addToPile("lb__mingxian", cards, true, skel.name, player)
    end
    data.disresponsive = true
    player:drawCards(2, skel.name)
  end,
})

return skel
